package com.cn.rzx.base.controller;

import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @Description:BaseController类
 * @author: Alex
 * @date: 2017年2月22日 上午10:37:01 Copyright (c) 2017, Samton. All rights reserved
 */
@Controller
public class BaseController {

    protected Map<String, Object> getResultMap(boolean rs) {
        return getResultMap(rs, null);
    }

    protected Map<String, Object> getResultMap(Object obj) {
        if (obj != null && obj instanceof Boolean) {
            return this.getResultMap((Boolean) obj);
        }
        return getResultMap(null, obj);
    }

    protected Map<String, Object> getResultMap(Boolean rs, Object obj) {
        Map<String, Object> map = new HashMap<String, Object>();
        boolean rsFlag = true;
        if (rs != null) {
            rsFlag = rs;
        } else {
            rsFlag = obj != null ? true : false;
        }
        map.put("rs", rsFlag ? 1 : 0);
        if (!rsFlag)
            return map;
        if (obj != null) {
                map.put("data", obj);
        }
        return map;
    }
}